class Solution:
    def sumGame(self, num: str) -> bool:
        def calculate(num, start, end):
            i = start
            numSum, markCnt = 0, 0
            while i < end:
                if num[i] == '?':
                    markCnt += 1
                else:
                    numSum += int(num[i])
                i += 1
            return numSum, markCnt

        leftSum, leftCnt = calculate(num, 0, len(num)//2)
        rightSum, rightCnt = calculate(num, len(num)//2, len(num))
        if leftCnt < rightCnt:
            leftCnt, rightCnt = rightCnt, leftCnt
            leftSum, rightSum = rightSum, leftSum
        if (leftCnt - rightCnt) % 2 != 0:
            return True

        return 9 * (leftCnt - rightCnt)//2 != rightSum-leftSum
